home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77669_nicwins_prop.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  25.8 KB  |  769 lines

  1. <% @Language=VbScript%>
  2. <% Option Explicit    %>
  3. <%
  4.     '---------------------------------------------------------------------------- 
  5.     ' nicwins_prop.asp: display and update the WINS properties of NIC.
  6.     ' Description:        this page displays the wins server properties of NIC and
  7.     '                    allows to change the properties
  8.     ' Copyright (c) Microsoft Corporation.  All rights reserved. 
  9.     '
  10.     ' Date            Description
  11.     ' 16-Jan-01        Creation date
  12.     ' 09-Mar-01    Modified date
  13.     '-----------------------------------------------------------------------------
  14. %>
  15.     <!-- #include virtual="/admin/inc_framework.asp"-->
  16.     <!-- #include file="loc_nicspecific.asp" -->
  17.     <!-- #include file="inc_network.asp" -->
  18. <% 
  19.     '-------------------------------------------------------------------------
  20.     ' Global Variables
  21.     '-------------------------------------------------------------------------
  22.     Dim G_objService        'Object to SWBEM service
  23.     Dim page                'Variable that receives the output page object when 
  24.                                 'creating a page 
  25.     Dim rc                    'Return value for CreatePage
  26.     
  27.     Dim SOURCE_FILE            'To hold source file name
  28.     SOURCE_FILE = SA_GetScriptFileName()
  29.        
  30.     '-------------------------------------------------------------------------
  31.     ' Global Form Variables
  32.     '-------------------------------------------------------------------------
  33.     Dim F_strNWadapter        'NIC adapter description
  34.     Dim F_nNWadapterindex    'NIC adapter index
  35.     Dim F_strWinservers        'Contains #-seperated list of WINS servers
  36.     Dim F_radSelected        'Which option is selected
  37.                             ' "1" means DHCP enabled
  38.                             ' "2" means Manual Settings
  39.     
  40.     'Create property page
  41.     rc=SA_CreatePage(L_WINSTASKTITLE_TEXT,"",PT_PROPERTY,page)
  42.     
  43.     'Serve the page
  44.     If(rc=0) then
  45.         SA_ShowPage(Page)
  46.     End if
  47.         
  48.     '-------------------------------------------------------------------------
  49.     'Function:                OnInitPage()
  50.     'Description:            Called to signal first time processing for this page.
  51.     '                        Use this method to do first time initialization tasks
  52.     'Input Variables:        PageIn,EventArg
  53.     'Output Variables:        PageIn,EventArg
  54.     'Returns:                True/False
  55.     'Global Variables:        None
  56.     '-------------------------------------------------------------------------
  57.     Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  58.         Call SA_TraceOut(SOURCE_FILE,"OnInitPage")
  59.         
  60.         'gets the default values of the wins server
  61.         OnInitPage = GetDefaultValues()
  62.     End Function
  63.     
  64.     '-------------------------------------------------------------------------
  65.     'Function:                OnServePropertyPage()
  66.     'Description:            Called when the page needs to be served.Use this 
  67.     '                        method to serve content
  68.     'Input Variables:        PageIn,EventArg
  69.     'Output Variables:        PageIn,EventArg
  70.     'Returns:                True/False
  71.     'Global Variables:        None
  72.     '-------------------------------------------------------------------------
  73.     Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg)
  74.         Call SA_TraceOut( SOURCE_FILE, "OnServePropertyPage")
  75.         
  76.         Call ServeCommonJavaScript()
  77.         
  78.         'serves the html content
  79.         Call ServePage()
  80.         
  81.         OnServePropertyPage = True
  82.     End Function
  83.     
  84.     '-------------------------------------------------------------------------
  85.     'Function:                OnPostBackPage()
  86.     'Description:            Called to signal that the page has been posted-back.
  87.     'Input Variables:        PageIn,EventArg
  88.     'Output Variables:        PageIn,EventArg
  89.     'Returns:                True/False
  90.     'Global Variables:        None
  91.     '-------------------------------------------------------------------------
  92.     Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
  93.         Call SA_TraceOut( SOURCE_FILE, "OnPostBackPage")
  94.         
  95.         'To get the value of NIC adapter index value after form is submitted
  96.         F_nNWadapterindex = Request.Form("hdnNWAdapterID")
  97.         
  98.         'List of winsservers after form has been submitted
  99.         F_strWinservers =Request.Form("hdnServerslist")
  100.         
  101.         ' The radio button to be selected - contains 1 or 2 only
  102.         F_radSelected = Request.Form("hdnRadioSelected")
  103.         
  104.         OnPostBackPage = True
  105.     End Function
  106.         
  107.     '-------------------------------------------------------------------------
  108.     'Function:                OnSubmitPage()
  109.     'Description:            Called when the page has been submitted for processing.
  110.     '                        Use this method to process the submit request.
  111.     'Input Variables:        PageIn,EventArg
  112.     'Output Variables:        PageIn,EventArg
  113.     'Returns:                True/False
  114.     'Global Variables:        In:G_objService-Getting WMI connection Object
  115.     '                        Out:F_nNWadapterindex-Getting NIC adapter Index
  116.     '                        Out:F_radSelected-Getting radio button selection
  117.     '                        Out:F_strWinservers-Getting new list wins servers
  118.     '                        L_(*)-Localization content
  119.     '-------------------------------------------------------------------------
  120.     Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
  121.         Call SA_TraceOut( SOURCE_FILE, "OnSubmitPage")
  122.         
  123.         'Getting WMI connection Object on error displays failure page
  124.         Set G_objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  125.         
  126.         call GetWINSConfiguration(1)
  127.         
  128.         'Updating the wins server settings
  129.         If SetWINSserverConfiguration() Then
  130.             OnSubmitPage = True
  131.         Else
  132.             OnSubmitPage = False
  133.         End if    
  134.         
  135.         'Release the object
  136.         set G_objService = nothing
  137.         
  138.     End Function
  139.            
  140.     '-------------------------------------------------------------------------
  141.     'Function:                OnClosePage()
  142.     'Description:            Called when the page is about closed.Use this method
  143.     '                        to perform clean-up processing
  144.     'Input Variables:        PageIn,EventArg
  145.     'Output Variables:        PageIn,EventArg
  146.     'Returns:                True/False
  147.     'Global Variables:        None
  148.     '-------------------------------------------------------------------------
  149.     Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
  150.         Call SA_TraceOut( SOURCE_FILE, "OnClosePage")
  151.         OnClosePage = TRUE
  152.     End Function     
  153.     
  154.     '-------------------------------------------------------------------------
  155.     'Function:                ServeCommonJavaScript
  156.     'Description:            Serves in initializing the values,setting the form
  157.     '                        data and validating the form values
  158.     'Input Variables:        None
  159.     'Output Variables:        None
  160.     'Returns:                None
  161.     'Global Variables:        None
  162.     '-------------------------------------------------------------------------
  163.     Function ServeCommonJavaScript()
  164. %>        
  165.         <Script language="JavaScript" src ="<%=m_VirtualRoot%>inc_global.js">
  166.         </Script>
  167.         
  168.         <Script language="JavaScript">
  169.                 
  170.             // Set the Intial Form load values 
  171.             function Init() 
  172.             {
  173.                 
  174.                 //If  "Obtain configuration from DHCP server " checkbox
  175.                    // is checked then disbable  configure manually controls
  176.                 if(document.frmTask.radIP[0].checked)
  177.                 
  178.                 {
  179.                     HandleControls(true)
  180.                     
  181.                 }
  182.                                             
  183.                 var intLength = document.frmTask.lstSelectwins.length;
  184.                             
  185.  
  186.                 
  187.                 switch(intLength)
  188.                 {
  189.                     case 0:    // If server list is empty, disable the Remove button
  190.                             document.frmTask.btnRemovewinsserver.disabled = true;
  191.                             document.frmTask.txtWinsserver.focus();
  192.             
  193.                             break;
  194.                             
  195.                     case 2:    // If server list contains two items, disable the Add button
  196.                             // select the first option in listbox
  197.                             document.frmTask.btnAddwinsserver.disabled = true;
  198.                             document.frmTask.txtWinsserver.disabled = true;
  199.                             document.frmTask.lstSelectwins.options[0].selected = true;
  200.                             document.frmTask.btnRemovewinsserver.disabled = false;
  201.                             break;
  202.                             
  203.                     default:// If server list contains one item, enable the Add button
  204.                             // select the first option in listbox
  205.                             document.frmTask.btnAddwinsserver.disabled = false;
  206.                             document.frmTask.btnRemovewinsserver.disabled = false;
  207.                             document.frmTask.lstSelectwins.options[0].selected = true;
  208.             
  209.                             break;
  210.                 }
  211.             
  212.                 //Disables Add button until a valid key is pressed.
  213.                 disableAddButton(document.frmTask.txtWinsserver,document.frmTask.btnAddwinsserver);
  214.             
  215.                 // disablingthe controls lisbox, textbox, Add &
  216.                 // remove buttons if "obtain configuration from dhcp server"
  217.                 // is checked
  218.                 if(document.frmTask.radIP[0].checked)
  219.                 
  220.                 {
  221.                     HandleControls(true)
  222.                     
  223.                 }
  224.                             
  225.             }
  226.             
  227.                 
  228.             // ValidatePage Function
  229.             // ------------------
  230.             // This function is called by the Web Framework as part of the
  231.             // submit processing. Use this function to validate user input. Returning
  232.             // false will cause the submit to abort. 
  233.             //
  234.             // This function must be included or a javascript runtime error will occur.
  235.             //
  236.             // Returns: True if the page is OK, false if error(s) exist. 
  237.             function ValidatePage() 
  238.             { 
  239.                 return true;    
  240.             }
  241.             
  242.             // SetData Function
  243.             // --------------
  244.             // This function is called by the Web Framework and is called
  245.             // only if ValidatePage returned a success (true) code. Typically you would
  246.             // modify hidden form fields at this point. 
  247.             //
  248.             // This function must be included or a javascript runtime error will occur.
  249.             //
  250.             function SetData() 
  251.             {
  252.             if(document.frmTask.radIP[0].checked)
  253.                     document.frmTask.hdnRadioSelected.value = "1"
  254.                 else
  255.                     document.frmTask.hdnRadioSelected.value = "2"
  256.             }
  257.             
  258.             //This function is called on click of ADD button validates the
  259.             // IP address and moves to the WINS servers listbox. 
  260.             function verifyIPaddress()
  261.             {
  262.                 var intErrvalue;
  263.                 ClearErr();
  264.                 intErrvalue =isValidIP(document.frmTask.txtWinsserver);
  265.                 
  266.                 if (intErrvalue == 0) 
  267.                 {    
  268.                     moveIPtoWINSServerListbox(document.frmTask.txtWinsserver.value); 
  269.                     document.frmTask.btnRemovewinsserver.disabled = false;
  270.                 }            
  271.                 else
  272.                 {
  273.                     SA_DisplayErr ( '<%=SA_EscapeQuotes(L_IP_ERRORMESSAGE)%>');
  274.                 }
  275.             }
  276.             
  277.  
  278.             //Function moves IP to WINSserver Listbox.
  279.             //Disables ADD button after adding 2 IP address.
  280.             function moveIPtoWINSServerListbox(IPaddress)
  281.             {
  282.                 var objWINSListbox = document.frmTask.lstSelectwins;
  283.                 var objRemoveButton =document.frmTask.btnRemovewinsserver; 
  284.                 var strWINSList = document.frmTask.hdnServerslist.value;
  285.                 
  286.                 //Function adds IP to WINS listbox and selects last IP.
  287.                 //Displays Error on Duplicate IP address.                
  288.                 if((addToListBox(objWINSListbox,objRemoveButton,IPaddress,IPaddress))==false)
  289.                 {
  290.                     SA_DisplayErr('<%=SA_EscapeQuotes(L_IPALREADYEXISTS_ERRORMESSAGE)%>');
  291.                 }
  292.                 else
  293.                 {
  294.                     document.frmTask.txtWinsserver.value = "";
  295.                 }
  296.                 //Add new IP to hidden text list of IP addresses
  297.                 strWINSList = strWINSList + IPaddress + "#";
  298.                 document.frmTask.hdnServerslist.value = strWINSList;
  299.                     
  300.                 //Disable the Add button if two or more WINS servers are listed
  301.                 if(objWINSListbox.length > 1) {
  302.                     document.frmTask.btnAddwinsserver.disabled = true;
  303.                     document.frmTask.txtWinsserver.disabled = true;
  304.                 }
  305.                 else
  306.                 {
  307.                     document.frmTask.txtWinsserver.disabled = false;
  308.                     disableAddButton(document.frmTask.txtWinsserver,document.frmTask.btnAddwinsserver);
  309.                     document.frmTask.txtWinsserver.focus();
  310.                 }    
  311.             }
  312.             
  313.             //Removes the selected IP from the WINSServerlistbox.
  314.             //Disables Remove button if Listbox is empty.
  315.             function removeIPFromWINSserverListbox() 
  316.             {
  317.                 var strRemovePattern;
  318.                 var objWINSListbox = document.frmTask.lstSelectwins ;    
  319.                 var strWINSList = document.frmTask.hdnServerslist.value;
  320.                 var intSelectedIndex;
  321.                 
  322.                 ClearErr();
  323.                 if (objWINSListbox.value != "")
  324.                 {
  325.                     intSelectedIndex = objWINSListbox.selectedIndex ; 
  326.                         
  327.                     //Removing the selected IP address from WINSstring
  328.                     strRemovePattern = objWINSListbox.value + "#";
  329.                     strWINSList =strWINSList.replace(strRemovePattern,"");
  330.                     document.frmTask.hdnServerslist.value = strWINSList;
  331.                     
  332.                     objWINSListbox.options[objWINSListbox.selectedIndex]= null;
  333.                         
  334.                     //Set focus on next list element,if list empty Disable the remove button
  335.                     if(objWINSListbox.length == 0)
  336.                     {
  337.                         document.frmTask.btnRemovewinsserver.disabled = true ;
  338.                         document.frmTask.txtWinsserver.focus();
  339.                     }
  340.                     else
  341.                     {
  342.                         if(objWINSListbox.length < 2)
  343.                         {
  344.                             disableAddButton(document.frmTask.txtWinsserver,document.frmTask.btnAddwinsserver);
  345.                             document.frmTask.txtWinsserver.disabled = false;
  346.                             document.frmTask.txtWinsserver.focus();
  347.                         }
  348.                         if(intSelectedIndex < objWINSListbox.length)
  349.                             objWINSListbox.options[intSelectedIndex].selected = true;
  350.                         else
  351.                             objWINSListbox.options[objWINSListbox.length-1].selected = true;
  352.                     }
  353.                 }
  354.             }
  355.             
  356.             
  357.             // Depending on the flag the controls lisbox, textbox, Add &
  358.             // remove buttons are disabled or enabled
  359.             function HandleControls(strFlag)
  360.                 {
  361.                     
  362.                     if ( strFlag ) 
  363.                     {
  364.                         document.frmTask.btnRemovewinsserver.disabled = true;
  365.                         document.frmTask.btnAddwinsserver.disabled = true;
  366.                         document.frmTask.txtWinsserver.disabled = true;
  367.                         if(document.frmTask.lstSelectwins.length > 0)
  368.                         {
  369.                             document.frmTask.lstSelectwins.selectedIndex = -1;
  370.                         }
  371.                         document.frmTask.lstSelectwins.disabled = true;
  372.                     }
  373.                     else
  374.                     {
  375.                         document.frmTask.btnRemovewinsserver.disabled = false;
  376.                         document.frmTask.btnAddwinsserver.disabled = false;
  377.                     }
  378.                 }
  379.             
  380.             //Handling Enabling of Wins controls and selects first item in the listbox and 
  381.             //sets the focus to Remove button
  382.             function enableWINSControls()
  383.             {
  384.                 document.frmTask.txtWinsserver.disabled = false;
  385.                 document.frmTask.txtWinsserver.value=""
  386.                 document.frmTask.txtWinsserver.focus()
  387.                 document.frmTask.lstSelectwins.disabled = false;
  388.                 
  389.                 // if any wins entries present, select the first
  390.                 // and enable the Remove button
  391.                 if(document.frmTask.lstSelectwins.length > 0)
  392.                 {
  393.                     document.frmTask.lstSelectwins.selectedIndex = 0;
  394.                     document.frmTask.btnRemovewinsserver.disabled = false;                    
  395.                 }
  396.             }
  397.             
  398.             //Handling Ok button when press 'Enter' after entering a value in 'Wins server address:' Text box            
  399.             function HandleOk(objWins)
  400.                 {
  401.                     if(window.event.keyCode!=27)
  402.                     {
  403.                         checkKeyforIPAddress(objWins);
  404.                     }
  405.  
  406.                     if(window.event.keyCode==0)
  407.                         {
  408.                             verifyIPaddress()
  409.                         
  410.                         }
  411.                 }
  412.         </script>
  413. <%    
  414.     End Function
  415.    
  416.     '-------------------------------------------------------------------------
  417.     ' Subroutine name:    ServePage
  418.     ' Description:        Serves few Javascript functions and helps in 
  419.     '                    displaying HTML of the page
  420.     ' Input Variables:    None.
  421.     ' Output Variables:    None
  422.     ' Return Values:    None.        
  423.     ' Global Variables:        In:G_objService-Getting WMI connection Object
  424.     '                        Out:F_nNWadapterindex-Getting NIC adapter Index
  425.     '                        Out:F_radSelected-Getting radio button selection
  426.     '                        Out:F_strWinservers-Getting new list wins servers
  427.     '                        L_(*)-Localization content    
  428.     '-------------------------------------------------------------------------
  429.     Sub ServePage()
  430.  
  431.         Err.CLear
  432.         On Error Resume Next
  433.         
  434.         Dim objNetAdapter    'To hold network adapter object instance
  435.         Dim strDHCPEnabled    'to hold the value Dhcp enabled or not        
  436.         
  437.         Call SA_TraceOut( SOURCE_FILE, "ServePage()")
  438.         
  439.         ' Getting the Network adapter objects
  440.         set objNetAdapter =    getNetworkAdapterObject(G_objService,F_nNWadapterindex)
  441.         
  442.         If Err.number <>0 then
  443.             Call SA_TraceOut( SOURCE_FILE, "Error in getting Network adapter Object-ServePage()")
  444.             Call SA_ServeFailurePage(L_NIC_ADAPTERINSTANCEFAILED_ERRORMESSAGE)
  445.             Exit Sub
  446.         End If    
  447.  
  448.         'Get Whether the DHCP is enabled on the NIC.
  449.         strDHCPEnabled = isDHCPenabled(objNetAdapter)
  450.         
  451.     %>    
  452.         <!--html content to be displayed-->
  453.         
  454.         <table border="0" cellspacing="0" cellpadding="2">
  455.     
  456.             <tr>
  457.                 <td class='TasksBody' nowrap colspan="4"><B><%=GetNicName(F_nNWadapterindex)%></B></td>
  458.             </tr>
  459.             
  460.             <tr>
  461.                 <td class='TasksBody' colspan="4"> </td>
  462.             </tr>
  463.     
  464.             <tr>
  465.                 <td class='TasksBody' nowrap >
  466.                     <%=L_CONFIGURATION_TEXT%>
  467.                 </td>
  468.                 <td class='TasksBody' colspan="3">
  469.                     <input type="radio" class="FormRadioButton" name="radIP" value="IPDEFAULT"
  470.                         <%     'if DHCP is disabled then disable
  471.                             'this radio button
  472.                             If Not strDHCPEnabled Then
  473.                                 response.write " Disabled"
  474.                             Else
  475.                                 response.write " Checked Disabled"
  476.                             End If
  477.                         %>
  478.                         onClick="EnableOK();HandleControls(true)">
  479.                         <%=L_OBTAINIPFROMDHCP_TEXT%>
  480.                 </td>
  481.             </tr>
  482.             
  483.             <tr>
  484.                 <td class='TasksBody'> </TD>
  485.                 <td class='TasksBody' nowrap colspan="3">
  486.                     <input type="radio" class="FormRadioButton" name="radIP" value="IPMANUAL"
  487.                         <%
  488.                             'if DHCP is disabled then disable this radio button
  489.                             If Not strDHCPEnabled Then
  490.                                 response.write " Checked Disabled"
  491.                             else
  492.                                 response.write " Disabled "
  493.                             End If
  494.                         %>
  495.                          onClick="EnableOK(); enableWINSControls();" >
  496.                         <%=L_NIC_IP_CONFIGUREMANUALLY%>
  497.                 </td>
  498.             </tr>
  499.             
  500.             <tr>
  501.                 <td class='TasksBody' nowrap colspan="4" align="right">
  502.                         <%=L_WINS_SERVER_ADDRESS_TEXT%>
  503.                 </td>
  504.             </tr>
  505.             
  506.             <tr>
  507.                 <td class='TasksBody' nowrap valign=top >
  508.                     <%=L_WINSADDRESSES_TEXT%>
  509.                 </td>
  510.                 
  511.                 <td class='TasksBody' valign="top" >
  512.                     <select name="lstSelectwins" style="width:200px" size="6" tabindex="1" class="FormField"> <% OutputWINSServersToListbox() %></select>
  513.                 </td>
  514.                 
  515.                 <td class='TasksBody' nowrap align=center valign=TOP >
  516.                 <%
  517.                     Call SA_ServeOnClickButtonEx(L_BUTTON_ADD_TEXT, "", "JavaScript:verifyIPaddress()", 60, 0, "DISABLED", "btnAddwinsserver")
  518.                 %>
  519.                       <br><br><br><br><br>
  520.                       
  521.                   <%
  522.                     Call SA_ServeOnClickButtonEx(L_BUTTON_REMOVE_TEXT, "", "javaScript:removeIPFromWINSserverListbox()", 60, 0, "DISABLED", "btnRemovewinsserver")
  523.                 %>
  524.                 </td>
  525.                 
  526.                 <td class='TasksBody' valign=top >
  527.                       <input class='FormField' type=text name="txtWinsserver" size=15 style="WIDTH:135px" maxlength="15" tabindex="3" onKeyUP="disableAddButton(txtWinsserver,btnAddwinsserver)" onKeypress="HandleOk(this)" >
  528.                 </TD>
  529.                 
  530.             </TR>
  531.             
  532.          </TABLE>
  533.                     
  534.         <input name="hdnServerslist" type="Hidden" value="<%=F_strWinservers%>" >
  535.         <input name="hdnNWAdapterID" type="Hidden" value="<%=F_nNWadapterindex%>" >
  536.         <input name="hdnRadioSelected" type="hidden"  value="<%=F_radSelected%>">
  537.  
  538. <%    
  539.         'destroying dynamically created objects
  540.         Set objNetAdapter=Nothing
  541.     
  542.     End Sub 
  543.     
  544.         
  545.     '-------------------------------------------------------------------------
  546.     ' Function Name:        GetWINSConfiguration
  547.     ' Description:            To retrieve the WINS configuration settings
  548.     '                        for the network adapter from system.
  549.     ' Input Variables:        nFormReload  - a flag value to differentiate 
  550.     '                        intial loading and form submition.                        
  551.     ' Output Variables:        None
  552.     ' Returns:                True/False
  553.     ' Global Variables:     In : F_nNWadapterindex - Index of adapter(WMI index number)
  554.     '                        In : L_INVALIDOBJECT_ERRORMESSAGE
  555.     '                        In : G_objService - WMI Connection Object
  556.     '                        Out: F_WINSERVER - #-separated list of WINS servers
  557.     '
  558.     'On Form intial loading gets the NIC adapter descrition and WINS servers
  559.     'from WMI .Displays the error message on failure of getting object from WMI.
  560.     'On form Reloading/submitting gets only description of NIC adapter.
  561.     '-------------------------------------------------------------------------
  562.     Function GetWINSConfiguration(nFormReload)
  563.  
  564.         Err.Clear    
  565.         On Error Resume Next        
  566.         
  567.         Const IPCONST="127.0.0.0"
  568.         
  569.         Dim objWinsCfg  'To hold Network adapter object instance
  570.         
  571.         Call SA_TraceOut( SOURCE_FILE, "GetWINSConfiguration()")
  572.     
  573.         Set objWinsCfg = G_objService.Get("Win32_NetworkAdapterConfiguration.Index=" _
  574.                              & chr(34) & F_nNWadapterindex & chr(34))
  575.         
  576.         'if initial load failure then ServeFailurePage called else SetErrMsg                     
  577.         
  578.         If Err.Number <> 0 Then
  579.             Call SA_TraceOut( SOURCE_FILE, "Error in getting Network adapter object-GetWINSConfiguration()")
  580.             
  581.             If nFormReload Then
  582.                 SA_SetErrMsg L_INVALIDOBJECT_ERRORMESSAGE & " (" & HEX(Err.Number) & ")" 
  583.             Else
  584.                 Call SA_ServeFailurePage( L_INVALIDOBJECT_ERRORMESSAGE)
  585.             End If                            
  586.             GetWINSConfiguration = FALSE
  587.             Exit Function
  588.         End If
  589.         
  590.         If (nFormReload) Then
  591.             ' Form being reloaded, keep the other values since they
  592.             ' are passed through the form.
  593.             Exit Function
  594.         End If
  595.  
  596.         F_strWinservers = ""
  597.         
  598.         'WMI returns '127.0.0.0' for server addresses that are not set
  599.         'so we must treat this value same as an unset address
  600.         If Len(Trim(objWinsCfg.WINSPrimaryServer)) > 0 Then
  601.             If objWinsCfg.WINSPrimaryServer <> IPCONST Then
  602.                 F_strWinservers = F_strWinservers & objWinsCfg.WINSPrimaryServer & "#"
  603.             End If
  604.         End If
  605.         
  606.         If Len(Trim(objWinsCfg.WINSSecondaryServer)) > 0 Then
  607.                 If objWinsCfg.WINSSecondaryServer <> IPCONST Then
  608.                 F_strWinservers = F_strWinservers & objWinsCfg.WINSSecondaryServer & "#"
  609.             End If
  610.         End If
  611.         GetWINSConfiguration = True
  612.         
  613.         'Destroying dynamically created objects
  614.         Set objWinsCfg=Nothing
  615.  
  616.     End Function
  617.     
  618.     
  619.     '-------------------------------------------------------------------------
  620.     ' Function name:        SetWINSserverConfiguration
  621.     ' Description:            Sets the WINS Configuration for the N/W Adapter.
  622.     ' Input Variables:        None
  623.     ' Output Variables:        None
  624.     ' Return Values:        True on sucess, False on error (and error msg
  625.     '                        will be set by SetErrMsg)
  626.     ' Global Variables:        In:     F_nNWadapterindex -Index of adapter (WMI index number)
  627.     '                        In:  F_strWinservers - #-separated list of WINS server IPs
  628.     '                        In:     G_objService - WMI Connection Object
  629.     '                        In:     L_SETWINSFAILED_ERRORMESSAGE 
  630.     '                        In:     L_INVALIDOBJECT_ERRORMESSAGE
  631.     '
  632.     ' Updates system with WINS servers as given by     F_strWinservers. If an error 
  633.     ' occurs, sets error message with SetErrMsg and exits with False.
  634.     '-------------------------------------------------------------------------
  635.     Function  SetWINSserverConfiguration()
  636.         
  637.         Err.Clear
  638.         On Error Resume Next    
  639.             
  640.         Dim objWinsCfg    'To hold Network adapter object instance
  641.         Dim strPrimAdd    'To hold Primary Wins server 
  642.         Dim strSecAdd    'To hold Secondary Wins server
  643.         Dim arrWinsSrv    'TO hold the array list of wins servers
  644.         Dim nValue        'To hold return value of the Wmi method
  645.         
  646.         Call SA_TraceOut( SOURCE_FILE, "SetWINSserverConfiguration()")            
  647.         
  648.         Set objWinsCfg = G_objService.Get("Win32_NetworkAdapterConfiguration.Index=" & _
  649.                          chr(34) & F_nNWadapterindex & chr(34))
  650.                          
  651.         If Err.Number <> 0 Then
  652.             Call SA_TraceOut( SOURCE_FILE, "Error in getting Network adapter object-SetWINSserverConfiguration()")
  653.             SA_SetErrMsg L_INVALIDOBJECT_ERRORMESSAGE & " (" & HEX(Err.Number) & ")"
  654.             SetWINSserverConfiguration = FALSE
  655.             Exit Function
  656.         End If
  657.         
  658.             arrWinsSrv = split(F_strWinservers, "#")
  659.             'Convert the array into a primary and secondary WINS server,
  660.             ' as required by WMI.
  661.             
  662.             strPrimAdd = ""
  663.             strSecAdd = ""
  664.             If Ubound(arrWinsSrv) > 0 Then
  665.                 strPrimAdd = arrWinsSrv(0)
  666.                     If Ubound(arrWinsSrv) > 1 Then
  667.                     strSecAdd = arrWinsSrv(1)
  668.                 End If
  669.             End If
  670.             
  671.             nValue = objWinsCfg.SetWINSServer(strPrimAdd, strSecAdd)
  672.             If (Err.Number <> 0 or nValue <> 0 )Then
  673.                 Call SA_TraceOut( SOURCE_FILE, "Error in setting wins server settings-SetWINSserverConfiguration()")
  674.                 SA_SetErrMsg L_SETWINSFAILED_ERRORMESSAGE & " (" & HEX(Err.Number) & ")"
  675.                 SetWINSserverConfiguration = false
  676.             Else
  677.                 SetWINSserverConfiguration = true
  678.             End If
  679.         
  680.         
  681.         'Destroying dynamically created objects
  682.         Set objWinsCfg=Nothing
  683.             
  684.     End Function
  685.     
  686.     
  687.     '-------------------------------------------------------------------------
  688.     ' Function Name:        OutputWINSServersToListbox
  689.     ' Description:            To display the WINS Servers in the LISTBOX.
  690.     ' Input Variables:        None.
  691.     ' Output Variables:        None.
  692.     ' Returns:                None.
  693.     ' Global Variables:     In:  F_WINSERVER - #-separated list of WINS server IPs
  694.     ' This function Outputs WINS servers to the listbox control in the Form.
  695.     '-------------------------------------------------------------------------
  696.     Function OutputWINSServersToListbox()
  697.         Err.Clear    
  698.         On Error Resume Next
  699.         
  700.         Call SA_TraceOut( SOURCE_FILE, "OutputWINSServersToListbox()")
  701.         
  702.         Dim arrWinsSrv    'To hold the Wins server list
  703.         Dim nIndex        'To hold the Wins server list  Index
  704.         
  705.         arrWinsSrv = split(F_strWinservers,"#")
  706.         nIndex = 0
  707.         
  708.         If (NOT IsNull(arrWinsSrv)) Then
  709.             If IsArray(arrWinsSrv) Then
  710.                 For nIndex = LBound(arrWinsSrv) to UBound(arrWinsSrv)
  711.                     If arrWinsSrv(nIndex) <> "" Then
  712.                         Response.Write "<OPTION VALUE=""" & arrWinsSrv(nIndex) & _
  713.                                 """ >" & arrWinsSrv(nIndex) & " </OPTION>"
  714.                     End If
  715.                 Next
  716.             End If
  717.         End If
  718.  
  719.     End Function
  720.  
  721.     '-------------------------------------------------------------------------
  722.     'Function:                GetDefaultValues
  723.     'Description:            gets default values of wins server setting
  724.     'Input Variables:        None
  725.     'Output Variables:        None
  726.     'Returns:                True/False
  727.     'Global Variables:        In:G_objService-Getting WMI connection Object
  728.     '                        Out:F_nNWadapterindex-Getting NIC adapter Index
  729.     '                        Out:F_radSelected-Getting radio button selection
  730.     '                        In:L_(*)-Localization content
  731.     '-------------------------------------------------------------------------
  732.     Function GetDefaultValues()
  733.         
  734.         Err.Clear
  735.         On Error Resume Next
  736.         
  737.         Dim objNetAdapter    'holds network adapter object
  738.         
  739.         Const DHCPON="ON"    'Const for dhcp on
  740.         Const DHCPOFF="OFF"    'Const for dhcp off
  741.         
  742.         Call SA_TraceOut( SOURCE_FILE, "GetDefaultValues()")
  743.         
  744.         'getting NIC adapter Index from area page
  745.         F_nNWadapterindex = Request.QueryString("PKey")
  746.  
  747.         'Getting WMI connection Object on error displays failure page
  748.         Set G_objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  749.         
  750.         set objNetAdapter =    getNetworkAdapterObject(G_objService,F_nNWadapterindex)        
  751.         
  752.         'getting default wins server settings from system
  753.         GetWINSConfiguration(0)
  754.         
  755.         'checking for the DHCP is enabled or not
  756.         If isDHCPenabled(objNetAdapter) Then
  757.             F_radSelected = DHCPON
  758.         Else
  759.             F_radSelected = DHCPOFF
  760.         End If
  761.  
  762.         GetDefaultValues=True
  763.         
  764.         'destroying dynamically created objects
  765.         Set objNetAdapter=Nothing
  766.     
  767.     End Function
  768. %>    
  769.